package com.useeinfo.oa.modules.maintaining.thread;

import com.useeinfo.framework.sugar.tools.DateTimeUtils;
import com.useeinfo.framework.sugar.tools.StringConverters;
import com.useeinfo.oa.modules.maintaining.biz.MaintainOrderBiz;
import com.useeinfo.oa.modules.maintaining.biz.PlanExecuteTimeBiz;
import com.useeinfo.oa.modules.maintaining.entity.PlanExecuteTime;
import com.useeinfo.oa.modules.threadUtil.ThreadUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("PlanSecheduled")
public class PlanSecheduled {

    private final static Logger logger = LoggerFactory.getLogger(PlanSecheduled.class);

    @Autowired
    private PlanExecuteTimeBiz planExecuteTimeBiz;
    @Autowired
    private MaintainOrderBiz maintainOrderBiz;




    public void execute() {
        logger.info("开始检查维保计划表");
        List<PlanExecuteTime> planExecuteTimes = planExecuteTimeBiz.createOrder(DateTimeUtils.formatDateToStringWithOnlyDate(new Date(), StringConverters.DATE_FORMAT_FULL));
        if (CollectionUtils.isNotEmpty(planExecuteTimes)) {
            logger.info("查询出：{}", planExecuteTimes.size());
            logger.info("开始进入线程");
            ThreadUtils.planExecuteTimes(maintainOrderBiz, planExecuteTimes);
        }
    }


}
